<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        var arr = [123,1,224,433,56,78,99];
        var max = arr[0];
        var min = arr[0];
        // 遍历数组，找出最大和最小的
        arr.forEach(function(value,index) {
            if(value > max) {
                max = value;
            }
            if(value < min) {
                min = value;
            }
        });
        // 最大值减去最小值，得出最大差值
        alert('最大差值：' + (max - min));
    </script>
</body>
</html>